﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_SignInSignOut_SignIn : BaseAdminPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btt_login_click(object sender, EventArgs e)
    {
        string mail = txt_username.Value.Trim();
        string pass = txt_pwd.Value.Trim();

        Page.Validate();
        if (!Page.IsValid) return;
        if (FormsAuthentication.Authenticate(mail, pass))
        {
            // Create the ticket, add the cookie to the response,
            // and redirect to the originally requested page
            string returnurl = FormsAuthentication.GetRedirectUrl(mail, false);
            if (returnurl.Contains("SignOut.aspx") || returnurl.Contains("Default.aspx") || returnurl.EndsWith("/admin/"))
            {
                FormsAuthentication.SetAuthCookie(mail, false);

                Response.Redirect("QuanLySanPham.aspx");
            }
            FormsAuthentication.RedirectFromLoginPage(mail, false);
        }
        else
        {
            // User name and password are not correct
            div_Error.Visible = true;
            Lbl_Error.Visible = true;
        }
    }
}
